<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Issue Tracker</title>
<%@include file="header.jsp"%>


<script>
	$(document)
			.ready(
					function() {

						var issueid = 0;
						$
								.ajax({
									type : "post",
									url : "../GetIssueDetail",
									datatype : "json",
									data : "issueid=0",
									success : function(data) {
										if (data.issuedetails.length > 0) {

											$("#issuelist").html("<div>");
											var i;
											for (i = 0; i < data.issuedetails.length; i++) {

												var bugid = "N.A.";

												if (data.issuedetails[i].bugid.length > 0) {
													bugid = data.issuedetails[i].bugid;
												}

												$("#issuelist")
														.append(
																"<div  onclick=\"toggledetails('"
																		+ data.issuedetails[i].id
																		+ "')\"   ondblclick=\"viewdetails('"
																		+ data.issuedetails[i].id
																		+ "')\"><div class=\" myissue \" >"
																		+ " <table  border=\"0\" width=\"100%\"><tr><td style=\"padding-top: 5px; padding-left: 5px; font-size: 18px;\" colspan=\"3\"  >"
																		+ "<span style=\"color: black\"> </span>"
																		+ data.issuedetails[i].issuetitle
																		+ "<br/>"
																		+ "</tr><tr><td style=\"padding-bottom: 5px; padding-left: 5px; font-size: 12px; \" colspan=\"3\">"
																		+ "by <span style=\"color: blue\" > "
																		+ data.issuedetails[i].createdby
																		+ "</span> on "
																		+ data.issuedetails[i].createdon
																		+ "</td></tr><tr><td style=\"padding-bottom: 5px; padding-left: 5px; padding-top:5px; width: 30% \">Bugid: "
																		+ bugid
																		+ "</td><td style=\"padding-bottom: 5px; padding-left: 5px; padding-top:5px; \">Module: "
																		+ data.issuedetails[i].module + " --> "
																		+ data.issuedetails[i].category + " --> "
																		+data.issuedetails[i].subcategory
																		+ "</td></tr><tr><td style=\"padding-bottom: 5px; padding-left: 5px; padding-top:5px; \" colspan=\"3\">Version: "
																		+ data.issuedetails[i].version
																		+ "</td></tr>"
																		//+"<tr><td style=\"padding-top: 5px;	padding-left: 5px;\" colspan=\"3\" ><hr>"
																		//+ data.issuedetails[i].issuedetails.substring(0,200)+ "</td></tr>"
																		+ "</div></table>"

																		+ "<div class=\"slidingDiv\" id='"+ data.issuedetails[i].id+"'  style=\"display: none;\"><hr> <div>"
																		+ data.issuedetails[i].issuedetails
																				
																		+ "</div>"
																		//+"<span style=\"padding-left: 5px;\"> Comment</span><span style=\"padding-left: 20px;\"> Like</span>"
																		//+ "<span	class=\"pull-right\" style=\"padding-right: 30px;\"> "
																		//+ "<img src=\"../images/like.png\" alt=\" \" style=\"padding-bottom: 5px;\" width=\"24\" height=\"24\" /> 7"
																		//+ "&nbsp;&nbsp;<img src=\"../images/comment.png\" alt=\"\" style=\"padding-bottom: 5px;\	width=\"24\" height=\"24\" /> 5 </span>"
																		+ "</div></div> <br/></div>"

														);
											}

										}

										$("#issuelist").append("</div>");

									},
									error : function(jqXHR, textStatus) {
										alert("Error viewing article: "
												+ textStatus);
									}

								});

					});

	var ishidden = 0;
	function toggledetails(issueid) {
		if (ishidden == 0) {
			$("#" + issueid).show();
			ishidden = 1;
		} else {
			$("#" + issueid).hide();
			ishidden = 0;
		}
	}

	function viewdetails(issueid) {
		//alert("View details: " + issueid);
		window.location = "viewissue.jsp?issueid=" + issueid;
		//+ issueid;

	}
</script>
</head>
<body>
	<%
		//System.out.println("Test");
	
		if (session.getAttribute("firstname") != null) {
			//System.out.println("firstname" + session.getAttribute("firstname"));
			
	%>

	<%@include file="toppanel.jsp"%>



	<h4 align="center" style="color: #A1A1A1; font-style: italic;">
		Recently Added Issues</h4>


	<div style="padding-left: 10%; padding-right: 10%">
		<div id="issuelist"></div>
	</div>

	<%
		} else {

			response.sendRedirect("../login.jsp");

		}
	%>
</body>


</html>